package org.nepu.scr.indexrate.converter.riskrate.equipmentdata.drillingdevice;

import cn.hutool.json.JSONUtil;
import org.nepu.scr.indexrate.vo.riskrate.equipmentdata.drillingdevice.SafetyFacilityLayout;

import javax.persistence.AttributeConverter;
import javax.persistence.Convert;

@Convert
public class SafetyFacilityLayoutConverter implements AttributeConverter<SafetyFacilityLayout, String> {
    @Override
    public String convertToDatabaseColumn(SafetyFacilityLayout safetyFacilityLayout) {
        return JSONUtil.toJsonStr(safetyFacilityLayout);
    }

    @Override
    public SafetyFacilityLayout convertToEntityAttribute(String s) {
        return JSONUtil.toBean(s, SafetyFacilityLayout.class);
    }
}
